package com.cskaoyan.javse.oop3._2inner._3exercise;

/**
 * @description: 案例
 * @author: wuguidong@cskaoyan.onaliyun.com
 **/

/**
 * 定义一个类,然后再在类中定义一个成员内部类
 * 了解一下成员内部类的使用
 *
 * Dog类
 * 成员内部类 Body: 用来描述Dog的身体
 *
 */
public class Demo {
    public static void main(String[] args) {
        Dog d = new Dog(1, "大黄", "大黄狗", "黄");
        d.printDog();
    }
}

//狗类
class Dog {
    private int age;
    private String name;
    private String breed;
    //将成员内部类的对象放进成员列表
    private Body body;

    //私有化该成员内部类
    private class Body {
        String color;
        public Body() {
        }
        public Body(String color) {
            this.color = color;
        }
    }
    public Dog(int age, String name, String breed, String color) {
        this.age = age;
        this.name = name;
        this.breed = breed;
        this.body = new Body(color);
    }
    public Dog() {
    }
    //写一个方法完成狗的属性打印
    public void printDog() {
        System.out.println("名字为" + name + "的" + body.color + "的狗,年龄是:" + age + ",它的品种是:" + breed);
    }
}
